<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="inputArray" value="1,2,3,4,5" placeholder="请输入数组元素，用逗号分隔">
    <button onclick="showResult('max')">最大值</button>
    <button onclick="showResult('min')">最小值</button>
    <p id="maxResult">最大值：无</p>
    <p id="minResult">最小值：无</p>

    <script>
        const showResult = (type) => {
            const array = document.getElementById('inputArray').value.split(',').filter(Boolean).map(Number);
            const result = array.length ? (type === 'max' ? Math.max(...array) : Math.min(...array)) : '无有效数据';
            document.getElementById(`${type}Result`).textContent = `${type === 'max' ? '最大值' : '最小值'}：${result}`;
        };
    </script>
</body>
</html>